package com.xiaotu.storage;

import com.xiaotu.common.util.Constants;
import com.xiaotu.common.util.DataRedisKeyUtils;
import com.xiaotu.common.util.SepratorUtil;
import com.xiaotu.storage.converter.AConverter;
import com.xiaotu.storage.converter.ConverterFactory;
import com.xiaotu.storage.model.CacheDataModel;
import net.sf.json.JSONObject;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @类名 TVBaiKeWorksInfoStorageProcessor
 * @日期 2021年2月23日
 * @作者 王艳龙
 * @功能 百度百科艺人对应作品剧基本信息记录
 */
@Component("TVBaiKeWorksInfoStorageProcessor")
public class TVBaiKeWorksInfoStorageProcessor extends AHSetStorageProcessor{

	public static final String[] FIELD_ARR = new String[]{"tvname","alias","showtype","sellcompany",
            "area","shootdate","shootaddress","issuingcompany","director","screenwriter","producer","actor",
            "timelength","releasetime","platform","firstplaytime","sets","tvtype","link"};
	
	private static final String[] CONVERT_ARR = new String[]{AConverter.STRING_CONVERT,AConverter.STRINGARRAY_CONVERT,
            AConverter.STRING_CONVERT,AConverter.STRINGARRAY_CONVERT,AConverter.STRING_CONVERT, AConverter.STRING_CONVERT,
            AConverter.STRINGARRAY_CONVERT,AConverter.STRINGARRAY_CONVERT,AConverter.STRINGARRAY_CONVERT,AConverter.STRINGARRAY_CONVERT,
            AConverter.STRINGARRAY_CONVERT,AConverter.STRINGARRAY_CONVERT,AConverter.STRING_CONVERT,AConverter.STRING_CONVERT,
            AConverter.STRINGARRAY_CONVERT,AConverter.STRING_CONVERT,AConverter.STRING_CONVERT,AConverter.STRING_CONVERT,AConverter.STRING_CONVERT};

    private static final boolean[] THROW_ARR = new boolean[]{true,true,true,true,true,true,true,true,
            true,true,true,true,true,true,true,true,true,true,true};

    @Override
    protected String getRedisKey(Date date)
    {
        return DataRedisKeyUtils.getKey(Constants.DataRedisKey.TV_BAIKE_WORKS_INFO_YYYYMMDD, date);
    }

    @Override
    public String process(JSONObject target, CacheDataModel cacheData, Date date)
    {
        return this.list2CSVLine(ConverterFactory.convert(target, FIELD_ARR, CONVERT_ARR,
                THROW_ARR), SepratorUtil.SEP_PIPE);
    }

    @Override
    public String getDataType()
    {
        return Constants.PageDataType.TV_RECORD;
    }

	@Override
	public String getTaskType() {
		return "TV_BAIKE_INFO_DATA";
	}
}
